ruler_enabled = false;

function initUi()
  app.registerUi({["menu"] = "Pen", ["callback"] = "pen", ["accelerator"] = "b"});
  app.registerUi({["menu"] = "Highlighter", ["callback"] = "highlight", ["accelerator"] = "h"});
  app.registerUi({["menu"] = "Select Region", ["callback"] = "lasso", ["accelerator"] = "g"});
  app.registerUi({["menu"] = "Eraser", ["callback"] = "eraser", ["accelerator"] = "e"});
  app.registerUi({["menu"] = "Undo", ["callback"] = "undo", ["accelerator"] = "z"});
  app.registerUi({["menu"] = "Redo", ["callback"] = "redo", ["accelerator"] = "<Ctrl><Shift>z"});
  app.registerUi({["menu"] = "Ruler", ["callback"] = "ruler", ["accelerator"] = "w"});
end

function pen()
  app.uiAction({["action"] = "ACTION_TOOL_PEN"})
end

function highlight()
  app.uiAction({["action"] = "ACTION_TOOL_HIGHLIGHTER"})
end

function lasso()
  app.uiAction({["action"] = "ACTION_TOOL_SELECT_REGION"})
end

function undo()
  app.uiAction({["action"] = "ACTION_UNDO"})
end

function redo()
  app.uiAction({["action"] = "ACTION_REDO"})
end

function eraser()
  app.uiAction({["action"] = "ACTION_TOOL_ERASER"})
end

function ruler()
  ruler_enabled = not ruler_enabled
  app.uiAction({["action"] = "ACTION_RULER", ["enabled"] = ruler_enabled})
end
